# -*- codeing = utf-8 -*-
# @Time : 2021/3/20 0020 13:38
# @Author : Alan Franklin
# @File : UI_register.py
# @Software: PyCharm
from tkinter import *
from tkinter.messagebox import *
from UI_globalstack import *
from UI_functions import *


class RegisterInterface(object):
    def __init__(self, master=None):
        self.root = master
        self.root.geometry('720x480')
        self.username = StringVar()
        self.password = StringVar()
        self.checkpassword = StringVar()
        self.CreatePage()

    def CreatePage(self):
        self.page = Frame(self.root)
        self.page.pack()
        Label(self.page, text='用户名：', font=('Arial', 12), height=1).grid(row=1, column=1, stick=W)
        Label(self.page, text='密码：', font=('Arial', 12), height=1).grid(row=2, column=1, stick=W)
        Label(self.page, text='确认密码：', font=('Arial', 12), height=1).grid(row=3, column=1, stick=W)
        Entry(self.page, textvariable=self.username, show=None).grid(row=1, column=2, columnspan=2, stick=E)
        Entry(self.page, textvariable=self.password, show='*').grid(row=2, column=2, columnspan=2, stick=E)
        Entry(self.page, textvariable=self.checkpassword, show='*').grid(row=3, column=2, columnspan=2, stick=E)
        Button(self.page, text='确认', height=2, command=self.RegisterCheck).grid(row=4, column=1, stick=W)
        Button(self.page, text='取消', height=2, command=self.GoBack).grid(row=4, column=2, stick=E)

    def RegisterCheck(self):
        username = self.username.get()
        password = self.password.get()
        checkpassword = self.checkpassword.get()
        showinfo(title='提示', message='功能暂未开放！')
        self.page.destroy()
        FunctionInterface(self.root)

    def GoBack(self):
        self.page.destroy()
        gs.mystack.Pop().CreatePage()
        gs.mystack.Push(self)